package com.shioirikukuri.config;

import com.shioirikukuri.redis.TableAvailabilityPreloadService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class DailyTableRefreshTask {

	private final TableAvailabilityPreloadService tableAvailabilityPreloadService;

	public DailyTableRefreshTask(TableAvailabilityPreloadService tableAvailabilityPreloadService) {
		this.tableAvailabilityPreloadService = tableAvailabilityPreloadService;
	}

	@Scheduled(cron = "0 0 0 * * ?") // 每天凌晨执行
	public void refreshNextDayTableData() {
		System.out.println("【定时任务】开始刷新明天的桌位数据到 Redis...");
		tableAvailabilityPreloadService.preloadNextDayTableData();
		System.out.println("【定时任务】明日桌位数据刷新完成。");
	}
}